<template>
  <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
    <van-swipe-item v-for="(img, index) in bannerImg" :key="index">
      <img v-bind:src="img" alt="" />
    </van-swipe-item>
  </van-swipe>
</template>

<script>
import axios from 'axios';
export default {
  name: "Banner",
  data() {
    return {
      // 接收后端返回的数据
      bannerImg: [],
    };
  },
  //   这一块是轮播图，，
  created() {
    axios({
      url: "http://localhost:3000/bannerImg",
    }).then((res) => {
      //把后端的数据赋给了bannerImg
      this.bannerImg = res.data;
      // console.log(this.bannerImg);
    });
  },
};
</script>

<style scoped>
.my-swipe {
  width: 3.5rem;
  height: 1.3rem;
  margin-top: 1rem;
  margin-left: 0.15rem;
}

.my-swipe .van-swipe-item img {
  width: 100%;
  height: 1.3rem;
}
</style>